<style>
    .bs-docs-example {
        cursor: move;
    }
</style>
<?php if (isset($project)) { ?>
    
    

    <?php if (isset($SprintStories)){
        echo '<h1>'.'Sprint '.($this->params['pass'][1] + 1).': '.$this->Html->link(h($project['Project']['name']),'view/'.$project['Project']['id']).'</h1>';
       
    }
    else{?>
       
                    <?php
                    echo '<h1>Proyecto :'.$this->Html->link(h($project['Project']['name']),'view/'.$project['Project']['id']).'</h1>';
                   
    } ?>
              
         
        
         <a href="<?php echo $this->base; ?>/projects/backlog/<?php echo $project['Project']['id'];  if (isset($SprintStories))echo '/'.($this->params['pass'][1]);?>" 
            class="btn btn-inverse pull-right"
            rel="tooltip" title="Vista Lista">
            <i class="icon-th-list icon-white"></i>
         </a>
         
         <a href="<?php echo $this->base; ?>/projects/backlogCard/<?php echo $project['Project']['id']; if (isset($SprintStories))echo '/'.($this->params['pass'][1]);?>" 
            class="btn btn-inverse pull-right"
            rel="tooltip" title="Vista Tarjeta">
             <i class="icon-list-alt icon-white"></i>
         </a>
         <?php
    ?>
    <?php if (!isset($SprintStories)){?>
        <p><small>Created: <?php echo $project['Project']['created']; ?></small></p>
        <p><?php echo h($project['Project']['description']); ?></p>
    <?php }  else {
        echo '<p></p><br/><p></p>';
    } ?>
    
    <?php if (isset($SprintStories)){
        $project['Story']=$SprintStories;
    }
    ?>
    
    <div class="row-fluid">
                <div class="span9">

                </div>
                    <?php
                    echo $this->element('stories/addStory',array('from'=> '2'));
                    ?>
         </div>
    <br/>
    
        <?php
       
        //var_dump($stories[0]['Story']);
        ?>
        <div class="alert alert-info">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>Tip:</strong> Para cambiar de estado, 
            arraste el User Story al título del estado correspondiente .
        </div>
        <div class="row-fluid">
                <div class="span12">
                    
            
        <?php for ($j=0;$j<4;$j++){ ?>
         <div class="span3">  
             <div id="estado<?php echo $j;?>" class="well" style="
                    background: <?php 
                    if ($j==0)echo "#1e221e";
                    if ($j==1)echo "#F89406";
                    if ($j==2)echo "#3A87AD";
                    if ($j==3)echo "#468847";
                 ?>;
                    color: white;
                    border-radius: 5px;
                    padding: 10px;
                ">
                 <?php 
                    if ($j==0)echo "ToDo";
                    if ($j==1)echo "Doing";
                    if ($j==2)echo "Review";
                    if ($j==3)echo "Done";
                 ?>
             </div>
         <?php 
          
            for ($i=0; $i<count($stories);$i++){    
    
             
                if ($stories[$i]['Story']['state']==$j){?>
                    <div id="<?php echo $stories[$i]['Story']['id'] ?>" class="bs-docs-example">
                        <ul class="nav nav-pills pull-right">
                            <?php if ($permiso){?>
                            <li>
                                <a data-toggle="modal" href="#editStory<?php echo $stories[$i]['Story']['id'] ?>" role="button"  ><i class="icon-edit"></i></a>
                                <?php 
                                    echo $this->element('stories/editStory',array("story" => $stories[$i]['Story'],"pSprints" => $project['Project']['sprints'],"from"=>3,"members"=>$members));

                                ?>
                            </li>
                            <?php } ?>
                            <li>
                                <a data-toggle="modal" href="#pokerStory<?php echo $stories[$i]['Story']['id'] ?>" role="button"  ><i class="icon-time"></i></a>
                                <?php 
                                    echo $this->element('stories/pokerStory',array("story" => $stories[$i],"pSprints" => $project['Project']['sprints'],"from"=>3,"members"=>$members));

                                ?>
                            </li>
                            <?php if ($permiso){?>
                            <li>
                            <?php
                            
                            echo $this->Form->postLink(
                                            '<i class="icon-trash"></i>', //le image
                                            '/stories/delete/'.$stories[$i]['Story']['id'].'/1', //,le url
                                            array('escape' => false,'confirm' => 'Are you sure?','class' => 'nav-pills'));

                                        ?>   
                            </li>
                            <?php } ?>
                        </ul>
                        <p> 
                            <?php echo $this->Html->link($i+1,array('controller'=>'stories','action'=>'view', $stories[$i]['Story']['id'])); ?>

                            <?php echo $stories[$i]['Story']['summary']?> 
                            <br/>
                            <?php echo $stories[$i]['Story']['detail']?> 
                            <br/>
                            <?php echo $this->Html->link('Sprint: '.($stories[$i]['Story']['sprint']+1),'backlogGrid/'.$project['Project']['id'].'/'.$stories[$i]['Story']['sprint']); ?>
                        </p>

                        </div>
                    <?php } 
                    
                    }?>
                    </div>
             <?php } ?>
        </div></div>
    
<?php } else {?>
    <br/>
    <div class="alert alert-info">
        Error de acceso.
    </div>
<?php }?>


